<template>
  <el-dialog
    :visible.sync="$attrs.visable"
    width="1120px"
    :before-close="handleClose"
    append-to-body
    title="转发"
    :close-on-click-modal='false'
  >
    <div class="flexbetween mb-20">
      <div class="flex">
        <div
          v-for="(item, index) in typeList"
          :key="index"
          class="typeitem commhover"
          :class="{ active: queryParams.type == item.id }"
          @click="handleType(item)"
        >
          {{ item.name }}
        </div>
      </div>
      <el-input
        v-model="queryParams.keyword"
        placeholder="昵称、备注、姓名、手机号、群名称"
        size="small"
        style="width: 260px"
        suffix-icon="el-icon-search"
      />
    </div>
    <div class="t_container">
      <div class="listbody flex flexwrap">
        <div
          class="listitem commhover flex"
          v-for="(item, index) in list"
          :key="index"
          @click="handleItem(item,index)"
        >
          <div class="avatarbox">
            <img
              src="//wework.qpic.cn/wwpic3az/646139_qhEaA8U0R8ya8Uz_1702871041/0"
              alt=""
            />
          </div>
          <div class="infobox">
            <div class="c_000 f-14 textover mb-2">肖洁</div>
            <div class="c_888999 f-12 textover">之星</div>
          </div>
          <div>
            <svg-icon
              v-if="item.checked"
              icon-class="ichecked2"
              class-name="f-16"
            />
            <svg-icon v-else icon-class="ichecked1" class-name="f-16" />
          </div>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button size="small" type="primary" @click="handleSubmit"
        >确定转发</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type:1,
        keyword: "",
      },
      typeList: [
        { name: "最近聊天", id: 1 },
        { name: "好友", id: 2 },
        { name: "群聊", id: 3 },
      ],
      list: [
        { id: 1, name: "测试群", checked: false },
        { id: 2, name: "测试群", checked: true },
      ],
    };
  },
  props: {
    messageItem: {
      type: Object,
      default: null,
    },
  },
  created() {
    console.log("item:", this.messageItem);
  },
  methods: {
    handleClose() {
      this.$emit("close"); //关闭弹窗;
    },

    handleType(item) {
      this.queryParams.type = item.id;
    },

    handleItem(item,index){
        item.checked = !item.checked
    },

    handleQuery() {},

    handlecheck(item) {
      console.log("item");
      this.grouplist.forEach((i) => {
        if (i.id == item.id) {
          i.checked = true;
        } else {
          i.checked = false;
        }
      });
      console.log("this.grouplist:", this.grouplist);
    },

    handleSubmit(){

    },
  },
};
</script>
<style lang="scss" scoped>
.typeitem {
  padding: 8px 18px;
  padding-top: 0;
  border-bottom: 2px solid #d8d8d8;
  margin-right: 10px;

  &.active {
    color: #3b74ff;
    border-color: #3b74ff;
  }
}
.t_container {
  min-height: 380px;
  max-height: 510px;
  overflow-y: auto;
}
.listbody {
//   height: 100%;
}
.h_box {
  height: 580px;
}
.listitem {
  width: 254px;
  margin-right: 14px;
  margin-bottom: 14px;
  padding: 16px !important;
  border: 1px solid #e9e9e9;
}
.avatarbox {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
  }
}
.infobox {
  margin: 0 10px;
  flex: 1 1;
}
.boxheader {
  padding: 0 12px;
  height: 42px;
  background: #fafafa;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 11;
}
.groupitem {
  width: 100%;
  padding: 3px;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }

  .groupleft {
    width: calc(100% - 50px);
  }
  .checkbox {
    width: 60px;
    .checkicon {
      height: 16px;
      width: 16px;
    }
  }
  .labelbox {
    background: #f1f1f4;
    border-radius: 2px;
    border: 1px solid #c1c1f1;
    color: #4b5a95;
    line-height: 20px;
    padding: 2px 8px;
  }
  .g_name {
    width: 90%;
  }
}
.accoutitem {
  padding: 6px 12px;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }
  .avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
  }
  .itemcontent {
    width: calc(100% - 52px);
  }
}
</style>